<!DOCTYPE html>
<!-- saved from url=(0037)http://127.0.0.1/wx/ybss/zhuce/zc.jsp -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

  <title>身份证认证</title>

  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no, email=no">
  <!--[if IE]>
  <script src="http://127.0.0.1:80/wx/ybss/js/html5shiv.min.js"></script>
  <![endif]-->


  <script type="text/javascript" src="../../script/constants.js"></script>
  <script src="../resource/md5.js"></script>
  <script src="../resource/jquery214.js"></script>
  <script src="../resource/fastclick.js"></script>
  <script src="../resource/jqueryweui.js"></script>
  </script><script src="../resource/picker.js"></script>
  <script src="../../script/api.js"></script>
  <script type="text/javascript" src="../../script/aes.js"></script>
  <script type="text/javascript" charset="UTF-8" src="../../script/naes.js"></script>
  <script type="text/javascript" src="../../script/modeecb.js"></script>
  <script type="text/javascript" src="../../script/constants.js"></script>
  <script src="../../script/tmd5.js"></script>
  <script type="text/javascript" charset="UTF-8" src="../../script/naes.js"></script>
  <script>


  </script>

  <style>

   .odiv{
	   display:table;
	   background:#fff;
	   width:100%;
	   padding:5px;
	   border-top:1px solid #E1E1E1; 
	   border-bottom:1px solid #E1E1E1;
   }
   .idiv{
	   float: left;
	   font-size:15px;
	   margin-left: 10px;
	   height:40px;
	   line-height:40px;
   }
   .div_text{
	   float: right;
	   height:40px;
	   line-height:40px;
	   width:50%;
	   color: #8d8d8d;
	   font-size:15px;
	   text-align: right;
	   overflow:hidden;
	   white-space: nowrap; 
	   text-overflow: ellipsis;
	   margin-right:10px;
   }
   .ipt{
     border:none;
     outline:none;
     width:100%;
     font-size:16px;
   }
   .select {
	    padding-top:5px;
	    padding-bottom:5px;
		border: 0;
		appearance:none;
		background: #fff;
		color: #000;
		outline: medium none;
		width:100%;
		height:100%;
		font-size: 16px;
	}
   
   body {
    overflow-x:hidden;
    margin: 0;
   }
   html {
    overflow-x:hidden;
   }
   
label {cursor:pointer;height:40px;}
label i {font-size:18px;font-style:normal;display:inline-block;width:18px;height:18px;text-align:center;line-height:18px;color:#fff;vertical-align:middle;margin:-2px 2px 1px 0px;border:#2489c5 1px solid;}
input[type="checkbox"] {display:none;}
input[type="checkbox"]:checked + i {background:#2489c5;}
input[type="checkbox"]:disabled + i {border-color:#ccc;}
input[type="checkbox"]:checked:disabled + i {background:#ccc;}
   
   .div_img{
       float: left;
       width: 30%;
       text-align: center;
       height: 160px;
       line-heigth: 160px;
    }
   
  </style>

</head>

<body style="background:url(../../image/bj.png) repeat-x 0;background-size:100%;">
<div style="background:url(../../image/mainbg.png) no-repeat right 0 bottom 0%;">
<div>
        <header id="statusBar">
		<div style="width:100%;display:table;background: #fff;position:fixed;border-bottom:1px solid #EAEAEA;z-index: 9999;height: 50px;" >
			<div style="float:left;width: 20%;height: 50px;line-height: 50px;" tapmode="presshover" onclick="api.closeWin();">
			  <div style="float:left;width: 30%;height: 50px;">
			   <img style="width: 24px;margin-top: 13px;" src="../../image/blc_back.png" />
			   </div>
			   <div style="float:left;width: 50%;">
			   返回
			   </div>
			</div>
			<div style="float:left;width: 60%;height: 50px;line-height: 50px;text-align: center;font-weight:bold;">
			 身份证认证
			</div>
		</div>
		</header>
		
        <div style="height:70px"></div>
        <div style="width: 100%;height: 45px;background: #fff;line-height: 45px;padding-left: 5%;font-weight:bold;border-bottom: 1px solid #EAEAEA;">证件信息</div>
        <div style="width: 100%;background: #fff;border-bottom: 1px solid #EAEAEA;padding-left: 5%;padding-right: 5%;display: table;padding-top: 10px;padding-bottom: 10px;">
            <div style="margin-bottom: 10px;display: table;">
               <div style="float: left;">
                 姓名：
               </div>
               <div id="name" style="float: left;">
               </div>
            </div>
            <div style="clear: both;"></div>
            <div>
               <div style="float: left;">
                 身份证号码：
               </div>
               <div id="idcard" style="float: left;">
               </div>
            </div>
        </div>  
         <div style="clear: both;"></div>
         <div id="examine" style="display:none;width:100%;height:160px;line-height: 160px;text-align: center;border-bottom: 1px solid #EAEAEA;background: #fff;color: #32CD32;">身份证认证已通过</div>
        <div id="photo" style="width: 100%;background: #fff;height: 160px;border-bottom: 1px solid #EAEAEA;padding-left: 5%;padding-right: 5%;display: none;">
            <div class="div_img">
               <div style="position: relative;top: 50%;transform: translateY(-50%);">
                  <div tapmode="presshover" onclick="choosePic(1)" style="width: 90px;height: 90px;margin: 0 auto;vertical-align: middle;">
                     <img id="rxz" src="../../image/jhzf/cardfront.png" style="width: 100%;height: 100%;border-radius: 5px;"/>
                  </div>
                  <div style="color: #000;">人像面</div>
              </div>
            </div>
            <div class="div_img">
               <div style="position: relative;top: 50%;transform: translateY(-50%);">
                  <div tapmode="presshover" onclick="choosePic(2)" style="width: 90px;height: 90px;margin: 0 auto;vertical-align: middle;">
                     <img id="ghz" src="../../image/jhzf/cardback.png" style="width: 100%;height: 100%;border-radius: 5px;"/>
                  </div>
                  <div style="color: #000;">国徽面</div>
              </div>
            </div>
            <div class="div_img">
               <div style="position: relative;top: 50%;transform: translateY(-50%);">
                  <div tapmode="presshover" onclick="choosePic(3)" style="width: 90px;height: 90px;margin: 0 auto;vertical-align: middle;">
                     <img id="scsfzz" src="../../image/jhzf/handcard.png" style="width: 100%;height: 100%;border-radius: 5px;"/>
                  </div>
                  <div style="color: #000;">手持身份证</div>
              </div>
            </div>
        </div>  
        
        <div id="submit" style="display:none;padding: 20px 0;width:100%;text-align: center;" onclick="uploadPic()" tapmode="presshover">
			<div  style="width:80%;height:35px;background: #27a8fa;margin:0 auto;color:#fff;line-height: 35px;border-radius:5px;">上传照片</div>
		  </div>
          <input type="hidden" id="pic1" />
          <input type="hidden" id="pic2" />
          <input type="hidden" id="pic3" />
</div>
		<div style="bottom:0;margin-top: 20px;width:100%;height:50px;text-align: center;">四川航天信息有限公司</div>
</div>		
<script>
   var merid = "";
   var name = "";
   var idcardNo = "";
	apiready = function(){
	   api.parseTapmode();
	   if(api.systemType == "ios"){
           document.getElementById("statusBar").style.background = "#298cb4";
       }
	   $api.fixStatusBar( $api.dom('header') );
	   var uiId;
       var UILoading = api.require('UILoading');
		UILoading.flower({
		    center: {
		        x: api.winWidth/2.0,          
		        y: api.winHeight/2.0 
		    },
		    size: 30,
		    mask: "rgba(0,0,0,0.5)",
		    fixed: true
		}, function(ret) {
		    uiId = ret.id;
		});
	   merid = api.pageParam.merid;
	   name = api.pageParam.name;
	   idcardNo = api.pageParam.idcardNo;
	   $("#name").html(name);
	   $("#idcard").html(idcardNo);
	   var callback = function(ret, err){
           if(ret){
             console.log(JSON.stringify(ret));
             if(ret.success == true){
               if(ret.MERLVL == "02"){
                  $("#photo").show();
                  $("#submit").hide();
                  var callback = function(ret, err){
				        UILoading.closeFlower({
						    id: uiId
					    });
				        document.getElementById("rxz").src = ret.certif1;
				        document.getElementById("ghz").src = ret.certif2;     
				        document.getElementById("scsfzz").src = ret.certif3; 
				   }
				   var content = {"merid":merid,"type":"0"};
				   apiAjax(JSON.stringify(content),url.queryPic,callback);
               }else{
                  UILoading.closeFlower({
					    id: uiId
				  });
                  $("#photo").show();
                  $("#submit").show();
               }
             }else{
               UILoading.closeFlower({
				    id: uiId
			   });
               api.alert({msg: ret.msg});
             }
           }else{
               UILoading.closeFlower({
				    id: uiId
			   });
               api.alert({msg: JSON.stringify(err)});
           }
       }
	   var content = {"merid":merid};
	   apiAjax(JSON.stringify(content),url.querMerlvl,callback);
	}
	
	function choosePic(i){
		api.confirm({
    		title: '选择图片获取方式',
    		msg: ' ',
    		buttons: ['相机', '图册']
		}, function(ret, err) {
    		var index = ret.buttonIndex;
    		if(index=="1"){
    			api.getPicture({
    				sourceType:'camera',
    				encodingType:'jpg',
    				destinationType:'base64',
    				quality:100,
    				targetWidth: 600,
    				targetHeight: 600,
    				allowEdit:'true',
    				saveToPhotoAlbum:'true'
                },function(ret,err){
                	if(i==1){
                	    document.getElementById("rxz").src = ret.base64Data;     
                	    $("#pic1").val(ret.data);             	
                	}else if(i==2){
                		document.getElementById("ghz").src = ret.base64Data;  
                		$("#pic2").val(ret.data);     
                	}else if(i==3){
                		document.getElementById("scsfzz").src = ret.base64Data; 
                		$("#pic3").val(ret.data);   
                	}
                });
    		}else if(index=="2"){
    			api.getPicture({
    				sourceType:'library',
    				encodingType:'jpg',
    				destinationType:'base64',
    				quality:100,
    				targetWidth: 600,
    				targetHeight: 600,
    				allowEdit:'true'
                },function(ret,err){
                    if(i==1){
                		document.getElementById("rxz").src = ret.base64Data;  
                		$("#pic1").val(ret.data);             	
                	}else if(i==2){
                		document.getElementById("ghz").src = ret.base64Data;  
                		$("#pic2").val(ret.data);     
                	}else if(i==3){
                		document.getElementById("scsfzz").src = ret.base64Data; 
                		$("#pic3").val(ret.data);   
                	}
                });
    		}
		});
	}
	
	function uploadPic(){
	    var uiId;
        var UILoading = api.require('UILoading');
		UILoading.flower({
		    center: {
		        x: api.winWidth/2.0,          
		        y: api.winHeight/2.0 
		    },
		    size: 30,
		    mask: "rgba(0,0,0,0.5)",
		    fixed: true
		}, function(ret) {
		    uiId = ret.id;
		});
		var a = "";//人像面
		var b = "";//国徽面
		var c = "";//手持身份证 
		var sp1 = document.getElementById("rxz").src.split(",");
		var sp2 = document.getElementById("ghz").src.split(",");
		var sp3 = document.getElementById("scsfzz").src.split(",");
		if(sp1.length > 1){
			a = sp1[1];
		}else{
		    api.alert({msg: "请选择身份证人像面照片"});
		    return;
		} 
		if(sp2.length > 1){
			b = sp2[1];
		}else{
		    api.alert({msg: "请选择身份证国徽面照片"});
		    return;
		} 
		if(sp3.length > 1){
			c = sp3[1];
		}else{
		    api.alert({msg: "请选择手持身份证照片"});
		    return;
		} 
		var path1 = $("#pic1").val();
		var path2 = $("#pic2").val();
		var path3 = $("#pic3").val();
		
        var callback = function(ret, err){
            UILoading.closeFlower({
			    id: uiId
			});
            if(ret){
                console.info("返回结果:"+JSON.stringify(ret));
                var picId1 = ret[0].pic1;
                var picId2 = ret[1].pic2;
                var picId3 = ret[2].pic3;
                var callback = function(ret, err){
			        if(ret){
			           if(ret.success == true){
			               api.alert({msg: "上传成功，请等待审核"});
			               api.closeWin();
			           }else{
			               api.alert({msg: "上传失败，原因："+ret.msg});
			           }
			        }else{
			           api.alert({msg: JSON.stringify(err)});
			        }
			    }
			    var para = {"type":"0","certifId1":picId1,"certifId2":picId2,"certifId3":picId3,"merid":merid,"name":name,"idcard":idcardNo};
			    apiAjax(JSON.stringify(para),url.updateMerinfo,callback);
            }else{
                api.alert({msg: JSON.stringify(err)});
            }
	  	}
	  	var img = {"pic1":path1,"pic2":path2,"pic3":path3};
   	  	fileAjax(JSON.stringify(img),"http://cloud.scjinsui.com:7003/paycloud/FulWeb",callback);
	}
</script>



</body></html>
